;
(function () {
  new Vue({
    el: '#voucherDetail',
    data() {
      return {
        id: hlUrlUtil.GetQueryString('id'), //凭证ID
        date: hlDateUtil.formatUTCDate(hlUrlUtil.GetQueryString('date'), 'yyyy-MM-dd'),
        abstract: '',
        data: {
          units: [],
          lenderSummaryValue: [],
          debtorSummaryValue: [],
        }
      }
    },
    filters: {
      formatDate: function (time) {
        if (time === undefined) return '--'
        return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd')
      },
    },
    mounted() {
			// console.log(this.id,hlUrlUtil.GetQueryString('id'))
      this.getDetail();
    },
    methods: {
      // 获取摘要文本
      getText(arr) {
        let text = []
        arr.map(item => {
          text.push(item.summaryValue)
        })
        return text + ''
      },


      getDetail() {
        hlhttp.get({
          url: 'acct/voucher_info',
          data: {
            id: this.id
          },
          success: data => {
            if (data.details && data.details.length) {
              let text = []
              data.details.map(item => {
                item.isShow = false
                item.summaryValue.map(el => {
                  text.push(el.summaryValue)
                })
              })
              this.abstract = text + ''
            }
            this.data = data
          }
        })
      },
      // 前往客户详情
      goToCustomer(id) {
        hlUrlUtil.goTo('customerDetails', {
          'page': 'customerMy',
          ddtab: true,
          id: this.data.customerId
        }, true)
      },
      // 前往合同详情
      goToContract() {
        hlUrlUtil.goTo('contractNewDeatil', {
          ddtab: true,
          proId: this.data.projectId,
          id: this.data.contractId,
          version: this.data.version
        }, true)
      },
      //前往账单
      goToBill(val) {
        if (val == 'N') {
          hlUrlUtil.goTo('billDetail', {
            'page': 'businessList',
            ddtab: true,
            id: this.data.billId,
            aid: this.data.contractId
          }, true)
        } else {
          hlUrlUtil.goTo('billDetail', {
            'page': 'businessList',
            ddtab: true,
            id: this.data.monthBillId,
            aid: this.data.contractId
          }, true)
        }

      },
      // 前往单元详情
      goToUnit(fyId) {
        hlUrlUtil.goTo('unitEditFloor', {
          'ddtab': true,
          fyId: fyId,
          projectId: this.data.projectId
        }, true)
      }
    },
  })
}())